package tw.twandroidproj.app.ui.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import java.util.List;
import tw.twandroidproj.app.R;
import tw.twandroidproj.app.model.JobApply;

public class mAdapter_tab3 extends RecyclerView.Adapter<mAdapter_tab3.ViewHolder> {
    private Context mcontext;
    private List<JobApply> mdata;
    public mAdapter_tab3(List<JobApply> data){
        Log.v("mAdapter_tab03","kn刷新");
        this.mdata=data;

    }
    static class ViewHolder extends RecyclerView.ViewHolder {
        TextView jobname;
        TextView applytime;
        Button del;
        public ViewHolder(View itemView) {
            super(itemView);
            jobname= (TextView) itemView.findViewById(R.id.jobapplied_name);
            applytime= (TextView) itemView.findViewById(R.id.jobapplyied_time);
            del= (Button) itemView.findViewById(R.id.delete03);
        }
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        if(mcontext==null){
            mcontext=parent.getContext();
        }
        View view= LayoutInflater.from(mcontext).inflate(R.layout.applystate_tab03_item,parent,false);
        final ViewHolder holder=new ViewHolder(view);
        holder.del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.v("mAdapter_tab03","点击了删除");
            }
        });
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        JobApply mjobApply=mdata.get(position);
        holder.jobname.setText(mjobApply.getJob_name());
        holder.applytime.setText(mjobApply.getCreated_at());
    }

    @Override
    public int getItemCount() {
        return mdata.size();
    }


}